package com.spirngcloud.alibabasentinelratelimiting.controller.mq.util.directStrategy;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @version V1.0
 * @Author 宋聚智
 * @Date 2019/10/24 10:30
 * @description
 * @Modify By：
 * @ModifyTime： 2019/10/24
 * @Modify marker：
 **/
@Configuration
public class DirectExchangeAndBinddingConf {
    @Bean(name="myDirectExchange")
    DirectExchange getDirectExchange(){
        //创建并返回名为My-Direct-Exchange
        return new DirectExchange("My-Direct-Exchange");
    }
    @Bean
    Binding bindingQueueOneToDirectExchange(@Qualifier("myFirstQueue") Queue myFirstQueue,
                                            @Qualifier("myDirectExchange") DirectExchange myDirectExchange){
        //将Queue绑定到myDirectExchange,并指定路由建为"routingKey.first"
        return BindingBuilder.bind(myFirstQueue).to(myDirectExchange).with("routingKey.First");
    }
}
